package com.example.demo.mapper;

import com.example.demo.entity.WorkersAndBookedTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 员工预约表 Mapper 接口
 * </p>
 *
 * @author Mr.wyy
 * @since 2024-05-31
 */
@Mapper
public interface WorkersAndBookedTimeMapper extends BaseMapper<WorkersAndBookedTime> {

    @Select("SELECT * FROM workers_and_booked_time WHERE flag = 1")
    public List<WorkersAndBookedTime> selectAllBooked();

    public List<WorkersAndBookedTime> selectByCriteria(WorkersAndBookedTime workersAndBookedTime);

    /**
     *
     * @param wbt_id 员工预约id
     * @return 影响行数
     */
    @Update("UPDATE workers_and_booked_time SET booked_num = booked_num - 1 WHERE wbt_id= #{wbt_id}")
    int bookedWorker(int wbt_id);

    /**
     *
     * @param wbt_id 员工预约id
     * @return 影响行数
     */
    @Update("UPDATE workers_and_booked_time SET booked_num = booked_num + 1 WHERE wbt_id= #{wbt_id}")
    int cancelBooked(int wbt_id);

    //通过预约id查询预约信息
    @Select("SELECT * FROM workers_and_booked_time WHERE wbt_id = #{wbt_id}")
    public WorkersAndBookedTime selectByWbtId(int wbt_id);
}
